package com.study.writeandreadobj;

import java.io.Serializable;
import java.util.Date;

/**
 * @author wali-pp
 *
 * 现在，如果我们穿行化GuestLoggingInfo的一个实例，将它写入磁盘，
 * 并且再将它从磁盘中读出，我们仍然看到读回的对象打印password 为 "NOT SET"。
 * 当从磁盘中读出某个类的实例时，实际上并不会执行这个类的构造函数，   
 * 而是载入了一个该类对象的持久化状态，并将这个状态赋值给该类的另一个对象。
 */
public class GuestLoggingInfo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;
	
	private Date loggingDate = new Date();   
    private String uid;   
    private transient String pwd;   
      
    public GuestLoggingInfo()   
    {   
        uid = "guest";   
        pwd = "guest";   
    }   

    @Override
	public String toString() {
		String passString = null;
		passString = pwd;
		
		if(pwd == null){
			passString = "NOT SET";
		}
		
		return "loggin info:\n " + "user:" + uid +
				"\n loggin date:" + loggingDate.toString() + 
				"\n password:" + passString;
	}
}
